﻿using UnityEngine;
using UnityEngine.UI;

public class AchiPanel : BasePanel
{
    //物品
    public GameObject obj;
    //父物体
    public Transform parent;

    public override void OnClose()
    {
        base.OnClose();

        EventManager.ReMsgDic("MsgAchiUI", CreateUI);
    }

    public override void OnInit()
    {
        base.OnInit();
        path="UI/Panel/AchiPanel";

        EventManager.AddMsgDic("MsgAchiUI", CreateUI);
    }

    public override void OnShow(params object[] par)
    {
        base.OnShow(par);

        SeekUI();
    }
    //找到UI
    public void SeekUI()
    {
        parent=item.transform.Find("Content");
        obj=item.transform.Find("Content/Slot").gameObject;
        obj.SetActive(false);
    }
    //生成UI
    public void CreateUI(MsgBase msgBase)
    {
        MsgAchiUI msg = (MsgAchiUI)msgBase;

        GameObject newObj = Instantiate(obj);
        newObj.transform.SetParent(parent, false);
        newObj.SetActive(true);
        newObj.transform.Find("Icon").GetComponent<Image>().sprite=msg.data.icon;
        newObj.transform.Find("Name").GetComponent<Text>().text=msg.data.achiName;
    }
}
//成就
public class MsgAchiUI:MsgBase
{
    public MsgAchiUI() { proName="MsgAchiUI"; }

    public MyAchiData data;
}
